import 'package:flutter/material.dart';
import 'package:banquanjie_app/app/services/screenAdapter.dart';
class Scriptlist extends StatelessWidget {
  final Map<String, dynamic> item;
  const Scriptlist({
    super.key,
    required this.item,
  });
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: ScreenAdapter.height(4)),
      width: ScreenAdapter.width(348),
      decoration: BoxDecoration(
        gradient: LinearGradient(begin: Alignment.bottomCenter, end: Alignment.topCenter ,colors: [Color(0xFFFFFFFF), Color(0xFFF2FFFB)]),
        borderRadius: BorderRadius.circular(ScreenAdapter.width(8)),
      ),
      clipBehavior: Clip.antiAlias,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          _buildInfoSection(),
          _buildOptionsSection(),
           
        ],
      ),
    );
  }
  Widget _buildInfoSection() {
    return Stack(
      children: [
        // Top icon
        if (item['topFlag'] != null && item['topFlag'] == true)
          Positioned(
            left: 0,
            top: 0,
            child: RotatedBox(
              quarterTurns: 90,
              child: Image.network(
                'https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/top_icon.png',
                width: ScreenAdapter.width(48),
                height: ScreenAdapter.width(48),
              )
            ),
          ),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                if (item['userEntrustFlag'] == 1)
                  Container(
                    padding: EdgeInsets.symmetric(horizontal: ScreenAdapter.width(6)),
                    margin: EdgeInsets.fromLTRB(ScreenAdapter.width(14), ScreenAdapter.width(10), 0, ScreenAdapter.width(10)),
                    decoration: BoxDecoration(
                      color: Color(0xFFF0F2F5),
                      borderRadius: BorderRadius.circular(ScreenAdapter.width(4))
                    ),
                    child: Text('自营', style: TextStyle(fontSize: ScreenAdapter.fontSize(24), color: Color(0xFF000000)))
                  ),
                Container(
                    padding: EdgeInsets.symmetric(horizontal: ScreenAdapter.width(6)),
                    margin: EdgeInsets.fromLTRB(ScreenAdapter.width(14), ScreenAdapter.width(10), 0, ScreenAdapter.width(10)),
                    decoration: BoxDecoration(
                      color: Color(0xFFF0F2F5),
                      borderRadius: BorderRadius.circular(ScreenAdapter.width(4))
                    ),
                    child: Text(item['worksTypeSecondName'], style: TextStyle(fontSize: ScreenAdapter.fontSize(24), color: Color(0xFF000000)))
                  )
              ]
            ),
            Container(
              alignment: Alignment.centerLeft,
              padding: EdgeInsets.only(left: ScreenAdapter.width(14)),
              height: ScreenAdapter.width(48),
              child: Text(item['worksTitle'], overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle(fontSize: ScreenAdapter.fontSize(28), color: Color(0xFF000000),fontWeight: FontWeight.w500),)
            ),
            Container(
              alignment: Alignment.centerLeft,
              padding: EdgeInsets.only(left: ScreenAdapter.width(14)),
              height: ScreenAdapter.width(46),
              child: RichText(
                text: TextSpan(
                  style: TextStyle(height: 1, fontSize: ScreenAdapter.fontSize(24), color: Color(0xFF000000)),
                  children: [
                    if (item['partYear'] != null)
                      TextSpan(
                        text: '${item['partYear']}年',
                      ),
                    if (item['episodes'] != null)
                      TextSpan(
                        text: ' | ${item['episodes']}集',
                      ),
                    if (item['projectProgressName'] != null)
                      TextSpan(
                        text: ' | ${item['projectProgressName']}',
                      )
                  ]

                )
              )
            ),
            if (item['worksTypeThreeName'] != null)
              Container(
                alignment: Alignment.centerLeft,
                height: ScreenAdapter.width(36),
                padding: EdgeInsets.only(left: ScreenAdapter.width(14)),
                child: Text('${ item['worksTypeThreeName'].replaceAll('|', ' / ') }', style: TextStyle(height: 1, fontSize: ScreenAdapter.fontSize(26), color: Color(0xFF999999)))
              ),
            Container(
              alignment: Alignment.centerLeft,
              padding: EdgeInsets.symmetric(horizontal: ScreenAdapter.width(14)),
              margin: EdgeInsets.only(bottom: ScreenAdapter.width(14)),
              child: Text(item['worksDetail'] != null ? '${item['worksDetail']}': '暂未上传...',  maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(height: 21 / 13,fontSize: ScreenAdapter.fontSize(26), color: Color(0xFF000000)))
            )
        ],
      )],
    );
  }
  Widget _buildOptionsSection() {
    return Container(
      padding: EdgeInsets.only(left: ScreenAdapter.width(14), right: ScreenAdapter.width(14)),
      height: ScreenAdapter.width(50),
      decoration: BoxDecoration(
        border: Border(top: BorderSide(color: Color(0xFFF4F7FC), width: ScreenAdapter.width(1)))
      ),
      child:  Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ClipRRect(
                child: Image.network(
                  'https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/rep_play_icon.png',
                  width: ScreenAdapter.width(14),
                  height: ScreenAdapter.width(14),
                )
              ),
              SizedBox(width: ScreenAdapter.width(12)),
              Text('${ item['viewNum'] }', style: TextStyle(fontSize: ScreenAdapter.fontSize(20), color: Color(0xFF000000))),
              SizedBox(width: ScreenAdapter.width(18)),
              ClipRRect(
                child: Image.network(
                  'https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/rep_collect_icon.png',
                  width: ScreenAdapter.width(14),
                  height: ScreenAdapter.width(14),
                )
              ),
              SizedBox(width: ScreenAdapter.width(12)),
              Text('${ item['collectNum'] }', style: TextStyle(fontSize: ScreenAdapter.fontSize(20), color: Color(0xFF000000))),
            ]
          ),
          if (item['worksTradeFlag'] == 0)
            Text(
              '仅展示',
              style: TextStyle(
                fontSize: ScreenAdapter.fontSize(20),
                color: Color(0xFF00B277),
              ),
            ),
        ]
      )
    );
  }
}